﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Data;

namespace QuizEngine.Data
{
    public class DbTable
    {
        private Type _type;
        private static List<PropertyInfo> _properties;

        protected DbTable()
        {
            Inintialize();
        }

        private void Inintialize()
        {
            if (_properties == null)
            {
                _type = this.GetType();
                _properties= new List<PropertyInfo>();
                foreach (PropertyInfo property in _type.GetProperties())
                {
                    if (property.GetCustomAttributes(typeof(DbTypeAttribute), true).Length != 0)
                    {
                        _properties.Add(property);
                    }
                    else if (property.PropertyType == typeof(Int32)
                        || property.PropertyType == typeof(String)
                        || property.PropertyType == typeof(Byte)
                        || property.PropertyType == typeof(Int16)
                        || property.PropertyType == typeof(DateTime)
                        || property.PropertyType == typeof(Char)
                        || property.PropertyType == typeof(Boolean)
                        || property.PropertyType == typeof(Double))
                    {
                        _properties.Add(property);
                    }
                }
            }
        }
        public void Add(DbTable table)
        {
            
        }
    }
}
